/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.ecommerce.usuario.view.bean;

import br.com.ecommerce.usuario.view.form.FormUsuario;
import br.com.ecommerce.util.view.JsfUtil;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;


/**
 *
 * @author rpateixeira
 */
@ManagedBean(name="usuarioBean")
@RequestScoped
public class UsuarioBean extends FormUsuario{

    /** Creates a new instance of UsuarioBean */
    public UsuarioBean() {
    }

    public String logout(){
        JsfUtil.setAtributeInSession("USUARIO_LOGADO", null);
        return null;
    }
    public String login(){
        if(this.usuarioServiceSession.isUsuarioLogado(getEntity())){
            return "login";
        }
        JsfUtil.addErrorMessage("Erro!!\n Usuario ou Senha Invalido");
        return null;
    }
    @Override
    public String insert() {
       return INSERT;
    }
    
    @Override
    public String update() {
        return UPDATE;
    }

    @Override
    public String remove() {
        return REMOVE;
    }

    @Override
    public String search() {
        return SEARCH;
    }

}
